package com.fgs.common.utils;

import android.text.TextUtils;
import android.util.Log;


/**
 * @author fgs
 * @date 2020/3/27
 **/
public class LogUtil {
    private static final String TAG = "TH";

    public static void print(String string) {
        print("", string);
    }


    public static void print(String tip, String string) {
        if (TextUtils.isEmpty(string)) return;

        //因为String的length是字符数量不是字节数量所以为了防止中文字符过多，
        //  把4*1024的MAX字节打印长度改为2001字符数
        int max_str_length = 2001 - TAG.length();
        int length;
        String logString;
        if (!TextUtils.isEmpty(tip)) {
            logString = tip + "-------" + string;
        } else {
            logString = string;
        }
        length = logString.length();

        //大于4000时
        while (length > max_str_length) {
            Log.i(TAG, logString.substring(0, max_str_length));
            logString = logString.substring(max_str_length);
            length = logString.length();
        }
        //剩余部分
        Log.i(TAG, logString);

    }
}
